home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / D-G / Generic MPW Tool.cpt / GenericTool.c next >
C/C++ Source or Header  |  1991-11-10  |  1KB  |  68 lines

  1. /*
  2.     GenericTool.c
  3.     Doug Wyatt, May 1991
  4.     
  5.     Freeware.
  6.     
  7.     Source for tiny MPW tool whose entire purpose is to load the rest
  8.     of itself from a code resource, PROC 981, which is (typically)
  9.     written in THINK C.
  10.     
  11.     Compile and link this file in MPW as follows (the tool is included
  12.     in this shareware release):
  13.  
  14.         C GenericTool.c
  15.         Link -w -t MPST -c 'MPS ' ∂
  16.             GenericTool.c.o ∂
  17.             "{CLibraries}"CRuntime.o ∂
  18.             "{Libraries}"ToolLibs.o ∂
  19.             "{CLibraries}"StdCLib.o ∂
  20.             "{CLibraries}"CInterface.o ∂
  21.             "{CLibraries}"CSANELib.o ∂
  22.             -o GenericTool
  23.  
  24.     Make a copy of Generic Tool and name it whatever you like.  
  25.     
  26.     PROC 981 should be built in THINK C as a code resource.  Merge it
  27.     into a copy of Generic Tool.  Its entry point must be declared:
  28.  
  29.         OSErr main(long argc, char *argv[], VoidFunc pPrintf, 
  30.             VoidFunc pFprintf, long stderr);
  31. */
  32.     
  33.  
  34.  
  35. #include    <types.h>
  36. #include    <stdio.h>
  37. #include    <ErrMgr.h>
  38. #include    <Errors.h>
  39. #include    <CursorCtl.h>
  40. #include    <Files.h>
  41. #include    <Resources.h>
  42. #include    <Strings.h>
  43.  
  44. extern printf(), fprintf();
  45.  
  46.  
  47. long main(argc,argv)
  48.     int        argc;
  49.     char    *argv[];
  50. {
  51.     long            status;    /* result code */
  52.     Handle procH;
  53.  
  54.     InitCursorCtl(nil);
  55.     procH = GetResource('PROC',981);
  56.     if (procH) {
  57.         MoveHHi(procH);
  58.         HLock(procH);
  59.         status = (* (short (*)())*procH)((long)argc, argv, printf, fprintf, stderr);
  60.         ReleaseResource(procH);
  61.     } else {
  62.         printf("%s - PROC 981 not found", argv[0]);
  63.         status = 1;
  64.     }
  65.     
  66.     return status;
  67. }
  68.